package com.example.cr.insect.enums;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;

public enum OperationResult {
    SUCCESS("S", "成功"),
    PARTIAL("P", "部分成功"),
    FAILED("F", "失败"),
    UNKNOWN("U", "未知");

    private String code;
    private String desc;

    OperationResult(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static List<HashMap<String, String>> getEnumList() {
        List<HashMap<String, String>> list = new ArrayList<>();
        for (OperationResult anEnum : EnumSet.allOf(OperationResult.class)) {
            HashMap<String, String> map = new HashMap<>();
            map.put("code", anEnum.code);
            map.put("desc", anEnum.desc);
            list.add(map);
        }
        return list;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    @Override
    public String toString() {
        return "OperationResult{" +
                "code='" + code + '\'' +
                ", desc='" + desc + '\'' +
                '}';
    }
}